// 字面量 json
// 用于数据解析
var Student={
    id:10001,
    name:"张三",
    scores:[
        {subject:"html",score:90},
        {subject:"js",score:90}
    ]
}


//function
function Student(id,name){
    this.id=id;
    this.name=name;
    this.scores=[
        {subject:"html",score:90},
        {subject:"js",score:90}
    ]
}
Student.prototype.sex="男";
Student.prototype.eat= function (food) {
    console.log("吃" + food);
}
var sut=new Student(1000,"张三");
sut.eat("米饭");
console.log(sut.sex);

//object
var stu2=new Object();
stu2.id=1000;
stu2.name="张三";
stu2.scores=[
    {subject:"html",score:90},
    {subject:"js",score:90}
]


function Student(id,name){
    this.id=id;
    this.name=name;
    this.scores=[
        {subject:"html",score:90},
        {subject:"js",score:90}
    ],
    this.eat=function (food) {
        console.log("吃" + food);
        return this;

    }
    this.sleep=function () {
        console.log("睡");
        return this;
    }
}

var stu=new Student(1001,"张三");
// 链式编程
stu.eat("").sleep();
// stu.sleep();